{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<h1 align=\"center\"> Linear Regression Python Tutorial </h1>"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "from sklearn.linear_model import LinearRegression\n",
    "import matplotlib.pyplot as plt\n",
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>x</th>\n",
       "      <th>y</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>82.583220</td>\n",
       "      <td>134.907414</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>73.922466</td>\n",
       "      <td>134.085180</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>34.887445</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "           x           y\n",
       "0  82.583220  134.907414\n",
       "1  73.922466  134.085180\n",
       "2  34.887445         NaN"
      ]
     },
     "execution_count": 67,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# any dataset will work\n",
    "# you can get the sample dataset at \n",
    "# https://github.com/mGalarnyk/Python_Tutorials/blob/master/Python_Basics/Linear_Regression/linear.csv\n",
    "\n",
    "raw_data = pd.read_csv(\"linear.csv\")\n",
    "raw_data.head(3)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "1) Preprocess the data to remove any points with a missing y value"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>x</th>\n",
       "      <th>y</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>82.583220</td>\n",
       "      <td>134.907414</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>73.922466</td>\n",
       "      <td>134.085180</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>61.839983</td>\n",
       "      <td>114.530638</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "           x           y\n",
       "0  82.583220  134.907414\n",
       "1  73.922466  134.085180\n",
       "3  61.839983  114.530638"
      ]
     },
     "execution_count": 68,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "filtered_data = raw_data[~np.isnan(raw_data[\"y\"])] #removes rows with NaN in them\n",
    "filtered_data.head(3)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "2) Fit a linear regression model using sklearn's LinearRegression"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "formula: y = [[ 1.5831968]]x + [ 4.4701969]\n"
     ]
    }
   ],
   "source": [
    "x_y = np.array(filtered_data)\n",
    "x, y = x_y[:,0], x_y[:,1]\n",
    "\n",
    "# Reshaping\n",
    "x, y = x.reshape(-1,1), y.reshape(-1, 1)\n",
    "\n",
    "# Linear Regression Object \n",
    "lin_regression = LinearRegression()\n",
    "\n",
    "# Fitting linear model to the data\n",
    "lin_regression.fit(x,y)\n",
    "\n",
    "# Get slope of fitted line\n",
    "m = lin_regression.coef_\n",
    "\n",
    "# Get y-Intercept of the Line\n",
    "b = lin_regression.intercept_\n",
    "\n",
    "# Get Predictions for original x values\n",
    "# you can also get predictions for new data\n",
    "predictions = lin_regression.predict(x)\n",
    "\n",
    "# following slope intercept form \n",
    "print \"formula: y = {0}x + {1}\".format(m, b) "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "3) Plot the Original Model (Black) and Predictions (Blue)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 70,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAhUAAAFkCAYAAACXcsmHAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAAPYQAAD2EBqD+naQAAIABJREFUeJzt3XuYpGV95//3dxrwgMswgkJYwQPTPSGJAWdARBlQaKye\n8fJ0uQl2k8tEfm7iiU1mfxs1iRtQTDZxV8F4WoPReAiNSi7R8JvphgFlGYOi06JJRGp6grqKoNjD\nQMAIM33//niqpqu6q7qe6n6qu6v6/bquvqCeurvq7odh6tP34XtHSglJkqTFWrPcHZAkSb3BUCFJ\nkgphqJAkSYUwVEiSpEIYKiRJUiEMFZIkqRCGCkmSVAhDhSRJKoShQpIkFcJQIUmSCrHgUBERfxQR\nt0fEgxFxX0R8PiIGGrR7Z0TcExGPRMSNEbF+1vOPi4gPRsT9EfFQRFwbEU9daL8kSdLyWMxIxWbg\n/cCZwCBwOHBDRDyh2iAi3gq8Gfhd4LnAw8B4RBxR8zpXAi8BXgWcA5wA/P0i+iVJkpZBFHWgWEQc\nC/wEOCeltKty7R7gf6aUrqg8Pgq4D/jtlNJnK49/Crw6pfT5SpsNwJ3A81JKtxfSOUmS1HFFrqk4\nGkjAFEBEPBM4Hrip2iCl9CDwNeCsyqXTgcNmtbkL+EFNG0mS1AUOK+JFIiLIpjF2pZS+U7l8PFnI\nuG9W8/sqzwEcBzxaCRvN2sx+r2OAEvA94N8X3XlJklaPxwPP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UmSCmGokCRJhTBUSJKkQhgqJElSIQwVkiSpEP8/\nqZogeaCsAa8AAAAASUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x11c944f50>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.scatter(x, y,  color='black')\n",
    "plt.plot(x, predictions, color='blue',linewidth=3)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "# Common Questions\n",
    "<a href=\"\"> </a> "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<a href=\"http://scikit-learn.org/stable/auto_examples/linear_model/plot_ols.html\">http://scikit-learn.org/stable/auto_examples/linear_model/plot_ols.html </a> "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Python [default]",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
